import request from '../../utils/request.js'

const state = {
	homeDataList:[],
	skuList:[],
}

const mutations = {
	SET_HOMEDATALIST(state,homeDataList){
		state.homeDataList = homeDataList
	},
	SET_SKULIST(state,skuList){
		state.skuList = skuList
	}
}

const actions = {
	async getHomeDataList({commit}){
		let result = await request('/getHomeData')
		console.log(result.data)
		commit('SET_HOMEDATALIST',result.data)
	},
	async getSkuList({commit}){
		let result = await request('/skuInfo')
		// console.log(result.data.skuInfo)
		commit('SET_SKULIST',result.data.skuInfo)
	}
	
	
}

const getters = {
	bannerList(state){
		return (state.homeDataList[0] || {}).content || []
	},
	phoneBigImg(state){
		return (state.homeDataList[1] || {}).content || []
	},
	phoneList1(state){
		return  (state.homeDataList[2] || {}).content || []
		// return result.map(item => {
		//  return	(item.content || []).map(item =>{
		// 	 return{
		// 		 src:item.src,
		// 		 uuid:item.uuid
		// 	 }
		//  })
		// })
	},
	phoneList2(state){
		return (state.homeDataList[3] || {}).content || []
	},
	computerBigImg(state){
		return (state.homeDataList[4] || {}).content || []
	},
	computerList1(state){
		return (state.homeDataList[5] || {}).content || []
	},
	computerList2(state){
		return (state.homeDataList[6] || {}).content || []
	},
	partsBigImg(state){
		return (state.homeDataList[7] || {}).content || []
	},
	partsList1(state){
		return (state.homeDataList[8] || {}).content || []
	},
	partsList2(state){
		return (state.homeDataList[9] || {}).content || []
	}
	
	
	
	}
	

export default {
	namespaced:true,
	state,
	mutations,
	actions,
	getters
	
}